package Testdmo1;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Date: 2024-03-01
 * Time：22:58
 */
public class J3_1 {
    //面对对象属性一：封装
}
   class Data1 {

        private int x;
        private int y;

        //    private 是私用的必须在这个 类 下使用
        private Data1(int x, int y) {
            this.x = x;
            this.y = y;
        }

        private int getX() {
            return x;
        }


        private int getY() {
            return y;
        }

        public static void main1(String[] args) {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNextInt()) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();

                Data1 data = new Data1(x, y);
                System.out.println(data.getX() + data.getY());
            }
        }

//    // 解决方法一：转化
//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNextInt()) {
//            int x = scanner.nextInt();
//            int y = scanner.nextInt();
//
//            Data data = new Data(x, y);
//            System.out.println(data.getX() + data.getY());
//        }
//    }
//
//
//
//}
//
//
//class Data {
//
//    private int x;
//    private int y;
//
//    public Data(int x, int y) {
//        this.x = x;
//        this.y = y;
//    }
//
//    public int getX() {
//        return x;
//    }
//
//    public int getY() {
//        return y;
//    }


    }

    // 继承
    class animal{
        public String name;
        public int age;
        public String color;

        public void  foodEat() {
            System.out.println();
        }

        public animal(String name)
        {
            this.name=name;
        }

    }

    class Dog extends animal{
        public Dog(String name){
            super(name);
        }
        public void bark() {
            System.out.println(name+"汪汪汪！");
        }
    }

    class Cat extends animal{
        public Cat(String name){
            super(name);
        }
        public void bark() {
            System.out.println(name+"喵喵喵!");
        }

        public static void main(String[] args) {
            Dog d1= new Dog("小黄");
            Cat c1=new  Cat("小白");
            d1.bark();
            c1.bark();
        }
    }






    class Base {

        private int x;
        private int y;

        public Base(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

    }

    class Sub extends Base {

        private int z;

        public Sub(int x, int y, int z) {
            //write your code here
            super(x,y);
            this.z=z;
        }

        public int getZ() {
            return z;
        }

        public int calculate() {
            return super.getX() * super.getY() * this.getZ();
        }



        public static void main1(String[] args) {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNextInt()) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();
                int z = scanner.nextInt();
                Sub sub1 = new Sub(x, y, z);


                System.out.println(sub1.calculate());
            }
        }



    }


    class Base1 {
        Base1() {
            System.out.print("Testdmo1.Base");
        }
    }

    class Alpha extends Base1 {

        public static void main2( String[] args ) {
            new Alpha();//1
            //调用父类无参的构造方法
            new Base1();//2
        }
    }




//class Testdmo1.X{
//    Testdmo1.Y y=new Testdmo1.Y();//1
//    public Testdmo1.X(){//2
//        System.out.print("Testdmo1.X");
//    }
//}
//class Testdmo1.Y{
//    public Testdmo1.Y(){//3
//        System.out.print("Testdmo1.Y");
//    }
//}
// class Testdmo1.Z extends Testdmo1.X{
//    Testdmo1.Y y=new Testdmo1.Y();//4
//    public Testdmo1.Z(){//5
//        System.out.print("Testdmo1.Z");
//    }
//    public static void main(String[] args) {
//        new Testdmo1.Z();
//    }
//}


    class X{
        Y y=new Y();//1
        public X(){//2
            System.out.print("Testdmo1.X");
        }
    }
    class Y{
        public Y(){//3
            System.out.print("Testdmo1.Y");
        }
    }
    class Z extends X{
        Y y=new Y();//4
        public Z(){//5
            System.out.print("Testdmo1.Z");
        }
        public static void main3(String[] args) {
            new Z();
        }
    }

//     Testdmo1.A 派生出子类 Testdmo1.B ， Testdmo1.B 派生出子类 Testdmo1.C ，并且在 java 源代码有如下声明：
//
//        1. Testdmo1.A a0=new Testdmo1.A();
//
//        2. Testdmo1.A a1=new Testdmo1.B();
//
//        3. Testdmo1.A a2=new Testdmo1.C();

    class A{
        public void printA(){
            System.out.println("Testdmo1.A");
        }

    }

    class B extends A {
        public void printA(){
            System.out.println("Testdmo1.B");
        }
    }


    class C extends B {
        public void printA(){
            System.out.println("Testdmo1.C");
        }


        public static void main(String[] args) {
            A a0=new A();

            A a1=new B();

            A a2=new C();
        }
    }

